﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:Wintellect.LiveFx.Cloudboard"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
  xmlns:liveFx="clr-namespace:Microsoft.LiveFX.ResourceModel;assembly=Microsoft.LiveFX.ResourceModel"
	x:Class="Wintellect.LiveFx.Cloudboard.ManagePermissions"
	x:Name="layout"
  WindowStyle="SingleBorderWindow"
  WindowStartupLocation="CenterOwner"
	Title="Share Your Clipboard"
	Width="640" Height="480" Margin="20,20,20,20" Icon="Resources\Clipboard.ico" >

  <Window.Resources>
    <SolidColorBrush x:Key="BlueGray" Color="#FF7092BE"/>
    <local:RoleValueConverter x:Key="roleValueConverter"/>
    <ObjectDataProvider
      MethodName="GetValues"
      ObjectType="{x:Type s:Enum}"
      x:Key="RoleNames">
      <ObjectDataProvider.MethodParameters>
        <x:Type TypeName="local:Role" />
      </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
    <ObjectDataProvider x:Key="Contacts"/>
    <!--<ObjectDataProvider
      x:Key="Contacts"
      ObjectType="{x:Type local:ManagePermissions}"
      MethodName="GetContacts"/>-->
  </Window.Resources>
  <Grid x:Name="LayoutRoot">
    <TextBlock Margin="8,8,8,0" VerticalAlignment="Top" Height="30" TextWrapping="Wrap"><Run FontSize="18" Foreground="{StaticResource BlueGray}"  Text="Choose the people you would like to share this clipboard with"/></TextBlock>
    <ListView x:Name="Members" Margin="8,86,8,65" IsSynchronizedWithCurrentItem="True">
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter
            Property="HorizontalContentAlignment"
            Value="Stretch" />
        </Style>
      </ListView.ItemContainerStyle>
      <ListView.View>
        <GridView AllowsColumnReorder="true"
              ColumnHeaderToolTip="Contacts who have access to this clipboard">
          <GridViewColumn 
            Width="300">
            <GridViewColumnHeader HorizontalContentAlignment="Stretch">
              <TextBlock>Contact Address</TextBlock>
            </GridViewColumnHeader>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <ContentControl x:Name="contactAddress">
                  <ContentControl.Template>
                    <ControlTemplate>
                      <TextBlock Text="{Binding Path=Email}"/>
                    </ControlTemplate>
                  </ContentControl.Template>
                </ContentControl>
                <DataTemplate.Triggers>
                  <DataTrigger Binding="{Binding Path=Existing}" Value="false">
                    <Setter TargetName="contactAddress" Property="Template">
                      <Setter.Value>
                        <ControlTemplate>
                          <ComboBox 
                            local:CueBannerService.CueBanner="&lt;&lt;Choose or enter an email address&gt;&gt;"
                            IsEditable="True"  
                            ItemsSource="{Binding Source={StaticResource Contacts}}"
                            HorizontalAlignment="Stretch"  
                            Text="{Binding Mode=TwoWay, Path=Email}" >
                          </ComboBox>
                        </ControlTemplate>
                      </Setter.Value>
                    </Setter>
                  </DataTrigger>
                </DataTemplate.Triggers>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
          <GridViewColumn
            Width="100">
            <GridViewColumnHeader HorizontalContentAlignment="Stretch">
              <TextBlock>Permission Level</TextBlock>
            </GridViewColumnHeader>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <ComboBox
                  ItemsSource="{Binding Source={StaticResource RoleNames}}" 
                  IsEditable="False" 
                  SelectedItem="{Binding Role}" 
                  Text="{Binding Path=Role, Converter={StaticResource roleValueConverter}}"/>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
          <GridViewColumn
            Width="200">
            <GridViewColumnHeader HorizontalContentAlignment="Stretch">
              Invitation status
            </GridViewColumnHeader>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <ContentControl x:Name="invitationStatus">
                  <ContentControl.Template>
                    <ControlTemplate>
                      <TextBlock Text="Invitation accepted."/>
                    </ControlTemplate>
                  </ContentControl.Template>
                </ContentControl>
                <DataTemplate.Triggers>
                  <DataTrigger Binding="{Binding Path=InvitationStatus}" Value="Owner">
                    <Setter TargetName="invitationStatus" Property="Template">
                      <Setter.Value>
                        <ControlTemplate>
                        </ControlTemplate>
                      </Setter.Value>
                    </Setter>
                  </DataTrigger>
                  <DataTrigger Binding="{Binding Path=InvitationStatus}" Value="Expired">
                    <Setter TargetName="invitationStatus" Property="Template">
                      <Setter.Value>
                        <ControlTemplate>
                          <local:Hyperlink>Expired. Click to re-invite.</local:Hyperlink>
                        </ControlTemplate>
                      </Setter.Value>
                    </Setter>
                  </DataTrigger>
                </DataTemplate.Triggers>
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
        </GridView>
      </ListView.View>
    </ListView>
    <TextBlock Margin="8,42,8,0" VerticalAlignment="Top" Height="44" Text="Select a name from your list of contacts, or type an email address" TextWrapping="Wrap" FontSize="12"/>
    <StackPanel
		Margin="8,8,8,8" 
		VerticalAlignment="Bottom" 
		Height="53" 
		Orientation="Horizontal" 
		HorizontalAlignment="Right"
		>
    	<Button x:Name="save" Width="85" Height="29" Content="Save" Margin="4" Click="save_Click"/>
    	<Button x:Name="cancel" Width="85" Height="29" Content="Cancel" Margin="4" Click="cancel_Click"/>
    </StackPanel>
  </Grid>
</Window>